home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-24 | 836 b | 58 lines | [TEXT/MPCC] |
- // NetBuf.cpp
-
- #include "NetPoint.h"
- #include <stdio.h>
-
-
- NetPoint::NetPoint()
- {
- fCloseOnDestroy = false;
- }
-
-
- NetPoint::~NetPoint()
- {
- if (fCloseOnDestroy)
- Close();
- }
-
-
- OSErr
- NetPoint::Open(
- const char *protocol)
- {
- OSStatus err;
-
- fEndpoint = OTOpenEndpoint(OTCreateConfiguration(protocol), 0, NULL, &err);
- if (!err) {
- fCloseOnDestroy = true;
- }
- return err;
- }
-
-
- OSErr
- NetPoint::Bind(
- short port)
- {
- OSStatus err;
- InetAddress inAddress;
- TBind inBuf = { { sizeof(InetAddress), sizeof(InetAddress), (UInt8*) &inAddress }, 0 };
- TBind outBuf = { { sizeof(InetAddress), sizeof(InetAddress), (UInt8*) &fMyAddress }, 0 };
-
- inAddress.fAddressType = AF_INET;
- inAddress.fHost = 0;
- inAddress.fPort = port;
- err = OTBind(fEndpoint, &inBuf, &outBuf);
-
- return err;
- }
-
-
- OSErr
- NetPoint::Close()
- {
- return OTCloseProvider(fEndpoint);
- }
-
-